<template>
  <el-form :model="form" label-width="120px">
 
        <JmInput  jmname="唯一标识" v-model="form.guid"   type="text"  ></JmInput>
        <JmInput  jmname="标题" v-model="form.title"   type="text"  ></JmInput>
        <JmEnum jmname="碎片类型" v-model="form.frag_type" :jv="inputtype" jtype="3"  ></JmEnum> 
        <JmInput  jmname="排序" v-model="form.order_id"   type="text"  ></JmInput>
        <JmEnum jmname="显示" v-model="form.is_show" :jv="{1: '是', 0: '否'}" jtype="2"  ></JmEnum>
 
           <JmEnum jmname="父栏目" v-model="form.cate_id" :jv="cate" jtype="4"  ></JmEnum>
 

      <el-form-item>
        <el-button type="primary" @click="onSubmit">Create</el-button>
        <el-button>Cancel</el-button>
      </el-form-item>
 
  </el-form>
</template>
 
<script>
import JmInput from "../../../components/form/JmInput.vue";
import JmEnum from "../../../components/form/JmEnum.vue";
export default {
  components: { JmInput, JmEnum },
  data() {
    return {
         form: { 
              guid:"",
              cate_id:0,
              title:"",
              frag_type:"text",
              frag_img:"",
              content:"", 
              order_id:1,
              is_show:1 

            },
      inputtype:{
            'text':'文本',
            'textarea':'多行文本',
            'num':'数字',
            'date':'日期',
            'datetime':'日期时间' ,
            'time':'时间',
            'color':'颜色选择',
            'img':'图片',
            'imgs':'多图片',
            'radio':'单选文字',
            'select':'单选下拉框',
            'selects':'多选下拉框'
      },
      cate :[
               
            ]
    };
  },

  mounted() {
    this.getDataList();
  },
  methods: {
    // 配置信息列表初始化
    async getDataList() {
      try {
         const res = await this.$api.Cate({select:1,cate_model:1}); 
          let ccc={}; 
          res.rows.forEach(element => { 
                ccc[element.id]=element.prefix+element.cate_name;
          }); 
          console.log(ccc,"查询")
          this.cate=ccc; 

      } catch (error) {
        /*console.error(error);*/
      }
    },
    onSubmit() {
      //  console.log(this.form);
      const res = this.$api.addSingle(this.form);
// this.$parent.handleClose();
       
       this.$parent.$parent.$parent.$parent.handleClose();   // 
      console.log(res);
    },
  },
};
</script>
<style>
.demo-tabs > .el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 32px;
  font-weight: 600;
}
.demo-tabs .custom-tabs-label .el-icon {
  vertical-align: middle;
}
.demo-tabs .custom-tabs-label span {
  vertical-align: middle;
  margin-left: 4px;
}
</style>